package com.sf.fy.uav.controller;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sf.fy.uav.common.enums.PopUpScreenStatusEnum;
import com.sf.fy.uav.common.request.operate.PopScreenReq;
import com.sf.fy.uav.common.request.operate.PopScreenRequest;
import com.sf.fy.uav.common.response.operational.PopUpScreenResponse;
import com.sf.fy.uav.common.utils.Rs;
import com.sf.fy.uav.entity.PopUpScreen;
import com.sf.fy.uav.service.IPopUpScreenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author LTQ
 * @since 2023-11-20
 */
@Controller
@RequestMapping("/sys/popUpScreen")
public class PopUpScreenRest {


    @Autowired
    private IPopUpScreenService iPopUpScreenService;

    public List<PopUpScreenResponse> getPopUpScreen() {
        return iPopUpScreenService.getPopUpScreen();
    }

    public Page<PopUpScreen> getPopUpScreenPageList(PopScreenRequest popScreenRequest) {
        return iPopUpScreenService.getPopUpScreenPageList(popScreenRequest);
    }

    public Rs<Integer> addPopScreen(PopScreenReq popScreenReq) {
        return iPopUpScreenService.savePopScreen(popScreenReq);
    }

    public Rs<Integer> editPopScreen(PopScreenReq popScreenReq) {
        return iPopUpScreenService.updateEntiyById(popScreenReq);
    }

    public Rs<Integer> delPopScreen(PopScreenReq popScreenReq) {
        return iPopUpScreenService.delPopScreenById(popScreenReq);
    }

    public List<PopUpScreen> getNoStartPopUpScreen() {
        return iPopUpScreenService.getNoStartPopUpScreen();
    }
    public List<PopUpScreen> getInProgressPopUpScreen() {
        return iPopUpScreenService.getInProgressPopUpScreen();
    }

    public void updateStatusBatch(List<String> ids) {
        iPopUpScreenService.update(new UpdateWrapper<PopUpScreen>().set("status",PopUpScreenStatusEnum.ON_DISPLAY.getStatus()).eq("deleted",false).in("id",ids));
    }

    public void updateInProgressStatus(List<String> inProgressPopUpScreenIds) {
        iPopUpScreenService.update(new UpdateWrapper<PopUpScreen>().set("status",PopUpScreenStatusEnum.ENDED.getStatus()).eq("deleted",false).in("id",inProgressPopUpScreenIds));
    }
}
